/**
 * 业务常量定义枚举
 * 
 */
import { GLOBAL } from './global'
/*成交报告- 对应唯一tCode
 *tCode   现货->S   长约->L  远期->F   代理->A   E->长约执行  C->背靠背
  isFuture: 1->远期
	isAgency: 1->代理
	bizMode: 1->闭口*/

export const R_NAME_ARR = [{
  tCode: 'S',
  titleNameP: '采购成交报告',
  titleNameS: '销售成交报告',
  newTitleNameP: '采购现货',
  newTitleNameS: '销售现货',
}, {
  tCode: 'L',
  titleNameP: '采购长约框架',
  titleNameS: '销售长约框架',
  newTitleNameP: '采购长约框架',
  newTitleNameS: '销售长约框架',
}, {
  tCode: 'F',
  titleNameP: '远期采购成交报告',
  titleNameS: '远期销售成交报告',
  newTitleNameP: '远期采购成交报告',
  newTitleNameS: '远期销售成交报告',
}, {
  tCode: 'A',
  titleNameP: '代理销售成交报告',
  titleNameS: '代理销售成交报告',
  newTitleNameP: '销售代理',
  newTitleNameS: '销售代理',
}, {
  tCode: 'E',
  titleNameP: '长约采购成交报告',
  titleNameS: '长约销售成交报告',
  newTitleNameP: '采购执行',
  newTitleNameS: '销售执行',
}, {
  tCode: 'C',
  titleNameP: '闭口采购供应商',
  titleNameS: '闭口销售客户',
  newTitleNameP: '闭口销售',
  newTitleNameS: '闭口销售',
}, {
  tCode: 'QH',
  titleNameP: '泉化现货价销售单',
  titleNameS: '泉化现货价销售单',
  newTitleNameP: '泉化销售',
  newTitleNameS: '泉化销售',
}];

export const GET_R_TITLE_NAME = (orderType, tCode) => {
  let attrName = null;
  if (GLOBAL.CURR_MODULE == '1.0') {
    attrName = orderType === 'P' ? 'titleNameP' : 'titleNameS';
  } else {
    attrName = orderType === 'P' ? 'newTitleNameP' : 'newTitleNameS';
  }
  R_NAME_ARR.map(item => {
    if (item.tCode === tCode) {
      titleName = item[attrName];
      return;
    }
  })
  return titleName;
}

/*isFuture: 1->远期
  isAgency: 1->代理
  bizMode: 1->闭口*/
export const R_FLAGS = {
  A: { isAgency: 1 },
  F: { isFuture: 1 },
  C: { bizMode: 1 },
  QH: { isQhXhXsBiz: 'Y' }
};

export const GET_R_FLAG = (tCode) => {
  if (R_FLAGS[tCode]) {
    return R_FLAGS[tCode];
  }
}

/*审批列表
 * 订单成交报告审批任务 ORDER_APP_APPROVAL_TASK 
 * 付款申请审批 ORDER_PAY_APPROVAL_TASK
 * 对应approveType  订单 -> O  付款申请 -> P  授信—> C  合同变更 -> A
*/
export const APPROVE_FLAGS = {
  'ORDER_APP_APPROVAL_TASK': {
    approveType: 'O',
    title: '订单'
  },
  'ZXY_ORDER_APPROVAL_TASK': {
    approveType: '1',
    title: '中新油'
  },
  'QH_SALE_CANCEL_APPROVAL_TASK': {
    approveType: 'QH',
    title: '泉化'
  },
  'ORDER_PAY_APPROVAL_TASK': {
    approveType: 'P',
    title: '付款申请'
  },
  'COMPANY_CREDIT_APPROVAL_TASK': {
    approveType: 'C',
    title: '授信'
  },
  'ORDER_UPDATE_APPROVAL_TASK': {
    approveType: 'A',
    title: '合同变更'
  }
}

/* 审批详情类型
 *
*/
export const APPROVE_DETAIL_FLAGS = {
  'PAY_APPROVE': {
    'TK': {
      title: '客户退款'
    },
    'DD': {
      title: '采购订单'
    },
    'RK': {
      title: '采购入库'
    },
    'FP': {
      title: '采购发票'
    },
    'FFP': {
      title: '费用发票'
    }
  }
}

//菜单默认图标维护
export const homeModulesIcon = {
  //一级菜单
  ApprovalIndexPage: require('../imgs/home/approval.png'),  //审批
  ReportIndexPage: require('../imgs/home/report.png'),  //报表
  PriceCenterIndexPage: require('../imgs/home/price.png'),  //价格中心
  FinacialStatementPage: require('../imgs/home/finacial-statement.png'),  //财务报表
  OperationIndexPage: require('../imgs/home/operation.png'),  //运维
  LogisticsIndexPage: require('../imgs/home/logistics.png'),  //物流
  WarehousingIndexPage: require('../imgs/home/warehousing.png'),  //仓储
  OrderListPage: require('../imgs/home/apply.png'),  //订单
  OperatePlanIndexPage: require('../imgs/home/operation.png'),  //经营计划
  RequirementPlanIndexPage: require('../imgs/home/approval.png'),  //客户需求计划
  SinoNewOrderListPage: require('../imgs/home/warehousing.png'),  //中新油
  LongIndexPage: require('../imgs/home/longPurchase.png'),
  LogisticsPage: require('../imgs/home/nd-logistics.png'),
  //二级菜单
  //价格中心
  ToQuotePage: require('../imgs/home/my-siter.png'),  //现货价提报

  ProductPricePage: require('../imgs/home/product-price.png'),  //商品价格
  LogisticsPricePage: require('../imgs/home/logistics.png'),  //物流价格
  CurrencyPricePage: require('../imgs/home/currency-price.png'),  //汇率价格
  PriceApprovalPage: require('../imgs/home/approval.png'),  //现货价审批
  //经营计划
  MyPlanPage: require('../imgs/home/my-plan.png'),  //我的计划
  //仓储
  WarehouseOutPage: require('../imgs/home/warehouse-out.png'),  //出库
  WarehouseInPage: require('../imgs/home/warehouse-in.png'),  //入库
  StockTackingPage: require('../imgs/home/stock-tacking.png'),  //盘点
  //客户需求计划
  RequirementPlanPage: require('../imgs/home/requirement.png'),  //客户需求计划
  RequirementPlanApprovalPage: require('../imgs/home/requirement-approvel.png'),  //客户需求计划审批
  //授信账单
  BillPage: require('../imgs/credit/bill.png'),  //授信账单
  // SinoNewOilQueryListPage: require('../imgs/home/sinoNewOrder.png'), //中新油查询列表
  //风控中心
  RiskControlPage: require('../imgs/risk/risk.png'),  //风控中心
  OccupyListPage: require('../imgs/risk/occupy.png'),//授信占用
  JudgementListPage: require('../imgs/risk/overdue.png'),//授信逾期
  ScanPage: require('../imgs/home/scan.png'), // 扫描
  TurnOrderList: require('../imgs/home/yxzd.png') // 意向管理
}

//授信类型
export const creditType = {
  'SX': "客户",   //赊销
  'YF': "供应商"  //预付
}

//需要授信的付款类型
export const CREDIT_TYPES = {
  'S': {
    '3': "货到付款",
    '5': '票到付款'
  },
  'P': {
    '2': "定金/保证金",
    '4': '款到发货'
  }
}

// 首页工作面板
export const REPORT_TYPE_LIST = [{
  reportArr: [{
    name: '销售现货',
    description: '创建销售现货成交',
    iconSrc: require('../imgs/home/nowPurcDeal.png'),
    tCode: 'S',
    orderType: 'S',
    periodType: 'S',
    permission: 'CRE001'
  }, {
    name: '销售长约',
    description: '创建销售长约成交',
    iconSrc: require('../imgs/home/longPurcDeal.png'),
    tCode: 'E',
    orderType: 'S',
    periodType: 'S',
    permission: 'CRE003'
  },
  // {
  //   name: '销售远期',
  //   description: '创建销售远期成交',
  //   iconSrc: require('../imgs/home/forwardPurcDeal.png'),
  //   tCode: 'F',
  //   orderType: 'S',
  //   periodType: 'S',
  // }, 
  {
    name: '销售代理',
    description: '创建销售代理成交',
    iconSrc: require('../imgs/home/agentPurcDeal.png'),
    tCode: 'A',
    orderType: 'S',
    periodType: 'S',
    permission: 'CRE002'
  }]
}, {
  reportArr: [{
    name: '闭口销售',
    description: '背靠背模式',
    iconSrc: require('../imgs/home/closePurchase.png'),
    tCode: 'C',
    orderType: 'P',
    periodType: 'S',
    permission: 'CRE006'
  }, {
    name: '泉化销售',
    description: '创建现货价销售单',
    iconSrc: require('../imgs/home/quanhua.png'),
    tCode: 'QH',
    orderType: 'S',
    periodType: 'S',
    permission: 'CRE007'
  }]
}, {
  reportArr: [{
    name: '采购现货',
    description: '创建采购现货成交',
    iconSrc: require('../imgs/home/nowSaleDeal.png'),
    tCode: 'S',
    orderType: 'P',
    periodType: 'S',
    permission: 'CRE004'
  }, {
    name: '采购长约',
    description: '创建采购长约成交',
    iconSrc: require('../imgs/home/longSaleDeal.png'),
    tCode: 'E',
    orderType: 'P',
    periodType: 'S',
    permission: 'CRE005'
  }
    // , {
    //   name: '采购远期',
    //   description: '创建采购远期成交',
    //   iconSrc: require('../imgs/home/forwardSaleDeal.png'),
    //   tCode: 'F',
    //   orderType: 'P',
    //   periodType: 'S',
    // }
  ]
}, {
  reportArr: [{
    name: '中新油销售',
    description: '创建中新油销售成交',
    iconSrc: require('../imgs/home/sinoNewSale.png'),
    tCode: 'SINONEWS',
    orderType: 'S',
    periodType: 'S',
    page: 'SinoNewOrderBaseInfoPage',
    permission: 'ZXY001'
  }, {
    name: '中新油采购',
    description: '创建中新油采购成交',
    iconSrc: require('../imgs/home/sinoNewPurchase.png'),
    tCode: 'SINONEWP',
    orderType: 'P',
    periodType: 'S',
    page: 'SinoNewOrderBaseInfoPage',
    permission: 'ZXY002'
  },
  {
    name: '中新油闭口',
    description: '创建中新油闭口成交',
    iconSrc: require('../imgs/home/sinoNewClose.png'),
    tCode: 'SINONEWC',
    orderType: 'S',
    periodType: 'S',
    page: 'SinoNewOrderBaseInfoPage',
    permission: 'ZXY003'
  }]
}]

export const MODULE_PAGE = {
  '1.0': {
    'OrderBaseInfoPage': 'OrderBaseInfoPage',
  },
  '2.0': {
    'OrderBaseInfoPage': 'orderBasePage',
  }
}

// 首页应用工具图标
export const APPLY_MENU = {
  'YWYJ001': {
    pageUrl: '',
    title: '资质到期',
  },
  'YWYJ002': {
    pageUrl: '',
    title: '授信到期',
  },
  'YWYJ003': {
    pageUrl: '',
    title: '订单逾期',
  },
  'YWYJ002': {
    pageUrl: '',
    title: '业务待审批',
  }
}

export const GET_PAGE = (pageName) => {
  return MODULE_PAGE[GLOBAL.CURR_MODULE][pageName]
}